package com.sgcc.nfc.lock.domain.model

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

enum class WarningStatus(val code: Int) {
    PENDING(0),
    HANDLED(1),
    CLOSED(2),
    UNKNOWN(-1);

    companion object {
        fun from(code: Int?): WarningStatus = when (code) {
            PENDING.code -> PENDING
            HANDLED.code -> HANDLED
            CLOSED.code -> CLOSED
            else -> UNKNOWN
        }
    }
}

enum class WarningType(val code: Int) {
    FORCED_OPEN(0),
    TIMEOUT(1),
    BATTERY_LOW(2),
    MALFUNCTION(3),
    UNKNOWN(-1);

    companion object {
        fun from(code: Int?): WarningType = when (code) {
            FORCED_OPEN.code -> FORCED_OPEN
            TIMEOUT.code -> TIMEOUT
            BATTERY_LOW.code -> BATTERY_LOW
            MALFUNCTION.code -> MALFUNCTION
            else -> UNKNOWN
        }
    }
}

@Parcelize
data class Warning(
    val warningId: Long,
    val warningType: WarningType,
    val lockId: Long?,
    val roomId: Long?,
    val roomName: String?,
    val warningContent: String?,
    val unlockDuration: Long?,
    val status: WarningStatus,
    val handleUserId: Long?,
    val handleUserName: String?,
    val handleTime: String?,
    val createTime: String?
) : Parcelable
